# encoding=utf-8
# 1 sp1
#####   #####
import config
import shutil
import os
class CBackup( ):
    _DEST_FILENAME = '%s%s.jpg'
    def __init__( self, SourcesDir, BackupsDir ):
        self._SourcesDirectory = SourcesDir
        self._BackupsDirectory = BackupsDir
        return None

    def BackupFile( self, FileName, ID ):
        if not os.path.exists(self._BackupsDirectory):
            os.makedirs(self._BackupsDirectory)
        if ID == -1:
            return False
        print( 'Backuping %s' % FileName )
        shutil.copyfile(os.path.join(self._SourcesDirectory, FileName), '%s%s[%d].jpg' % (self._BackupsDirectory, FileName, ID))
        return True

